package com.yanqu.road.server.manger.union.listener;

import com.yanqu.road.entity.enums.eUnionSyncType;
import com.yanqu.road.entity.union.cross.CrossUnionInfo;
import com.yanqu.road.entity.union.cross.CrossUnionMember;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.manger.ICrossUnionSyncListener;
import com.yanqu.road.server.manger.rank.RankMgr;
import com.yanqu.road.server.manger.thirdparty.ThirdPartyMgr;
import com.yanqu.road.server.manger.union.CrossUnionMgr;

import java.util.List;

public class UnionCreateListener implements ICrossUnionSyncListener {

    @Override
    public void notifySync(int syncType, long playerId, CrossUnionInfo unionInfo, List<CrossUnionMember> memberList) {


        if(syncType == eUnionSyncType.CreateUnion.getValue()){

            CrossUnionMember member = CrossUnionMgr.getUnionMember(unionInfo.getUnionUid(), playerId);
            if(member != null && member.getServerId() == GameServer.getInstance().getServerId()){
                RankMgr.changeUnionRank(unionInfo);
            }
            //商会上报
            ThirdPartyMgr.unionNameReport(unionInfo.getUnionUid(), unionInfo.getUnionName());
            ThirdPartyMgr.unionNoticeReport(unionInfo.getUnionUid(), unionInfo.getOutNotice());
        }

    }

}
